home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / svgadiag.zip / svgadiag.c next >
C/C++ Source or Header  |  1994-11-21  |  20KB  |  542 lines

  1. /*************************************************************************
  2.  
  3.   SVGADIAG.C
  4.  
  5.   Written by Eric Jorgensen (1994)
  6.  
  7.   This is Turbo C source code for my SVGA DIAGNOSTIC UTILITY.  Feel
  8.   free to modify it, use it, play with it, or even give it away.
  9.   Just don't sell it for money or give yourself credit for what
  10.   you didn't write.
  11.  
  12.   To avoid confusion, please do not publish modifcations of this
  13.   code as a version of "SVGADIAG" or "SVGA DIAGNOSTIC UTILITY".
  14.  
  15.   NOTES:  SVGACC is a SVGA graphics library written by Stephen Balkum
  16.           and Daniel Sill.  You can upload a shareware version just
  17.           about anyplace, but try looking in Simtel for svgacc21.zip
  18.           in one of the programming directories.
  19.  
  20.           Compile with a large memory model.
  21.  
  22. *************************************************************************/
  23.  
  24. #include <stdio.h>
  25. #include <conio.h>
  26. #include "svgacc.h"
  27. #include <alloc.h>
  28. #include <dos.h>
  29.  
  30. char *version = {"1.0"};
  31.                                  // Video card ID's for whichvga()
  32. char *card[21] = { "Acumos AVGA2/3",
  33.                     "ATI",
  34.                     "Ahead V5000 Ver A",
  35.                     "Ahead V5000 Ver B",
  36.                     "Chips and Technologies 82C45x",
  37.                     "Cirrus Logic CL-GD",
  38.                     "Everex Micro Enhancer",
  39.                     "Genoa",
  40.                     "NCR",
  41.                     "Oak Technologies OTI",
  42.                     "Paradise/Western Digital",
  43.                     "Realtek RT3106",
  44.                     "Trident 8800CS, 8900B/C/CL/CX, 90x0",
  45.                     "Tseng Labs ET3000",
  46.                     "Tseng Labs ET4000",
  47.                     "VESA compatible",
  48.                     "Video 7 HT",
  49.                     "Avance Logic AL2101",
  50.                     "MXIC MX",
  51.                     "Primus P2000"
  52.                     "Undefined"
  53.                   };
  54.                                  // mouseID's for Mouseinfo()
  55. char *mice[6] = { "Unknown",
  56.                   "Bus",
  57.                   "Serial",
  58.                   "Inport",
  59.                   "PS/2",
  60.                   "HP" };
  61.  
  62.  
  63. /**************************************************************************
  64.   main()
  65.  
  66.     DESCTRIPTION: No other functions here.  This one simply calls a few
  67.                   routtines to measure the performance and compatability
  68.                   of the graphics card.
  69.  
  70. **************************************************************************/
  71. main()
  72. {
  73.   int blkget_return,mouse_drvmaj,mouse_drvmin,mousetype,mouseirq;
  74.   int pageactive_return,pagedisplay_return;
  75.   int res640_return, res800_return,res1024_return,res1280_return;
  76.   int cputype,video_memory,whichmouse_return;
  77.   int videocard;
  78.   int i,j,k,t;
  79.   RGB palette[256];
  80.   FILE *output;
  81.   RasterBlock *blk;
  82.   char string[255];
  83.   struct date today;
  84.   struct time now;
  85.   union REGS myregs;
  86.   struct SREGS mysregs;
  87.   char vesainfobuffer[512];
  88.   char r;
  89.   byte vermaj,vermin,*pt;
  90.   char far *OEMname,*modes;
  91.   long int pps,c;
  92.                                  // Warn the user about Winndoze
  93.   clrscr();
  94.   printf("\n\n\n\n\n\t\t*WARNING* This program is NOT Windows friendly.\n");
  95.   printf("\n\t\tYou should quit Windows before running SVGADIAG.\n\n");
  96.   printf("\t\tPress 'C' to continue anyway, or any other key to quit.");
  97.  
  98.   if(toupper(getch()) != 'C') exit(1);
  99.  
  100.   clrscr();                            // clear screen
  101.   printf("########################################\n");
  102.   printf("#                                      #\n");
  103.   printf("#       SVGA DIAGNOSTIC UTILITY        #\n");
  104.   printf("#            Version %s               #\n",version);
  105.   printf("#                                      #\n");
  106.   printf("#   Written by Eric Jorgensen (1994)   #\n");
  107.   printf("#                                      #\n");
  108.   printf("########################################\n\n\n");
  109.  
  110.  
  111.   blk = (RasterBlock *)malloc(11000); // allocate memory for graphics block
  112.   if(!blk) {
  113.     printf("Whoops!  Could not allocate 20Kb for graphics block.\n");
  114.     exit(1);
  115.   }
  116.  
  117.   output = fopen("SVGAOUT.txt","w");  // open output file
  118.   if(!output) {
  119.     printf("Whoops!  Could not open an output file.\n");
  120.     exit(1);
  121.   }
  122.                                       // Starting Instructions
  123.   printf("INSTRUCTIONS:\n");
  124.   printf("  The data from this program will be dumped to a file called SVGAOUT.TXT.\n");
  125.   printf("  Please edit this file (even if this program crashes), answer the\n");
  126.   printf("  questions at the beginning about your computer system, and send it\n");
  127.   printf("  via email to:\n\n");
  128.   printf("\t\tsmeagol@rt66.com\n\n");
  129.   printf("Note: This Survey ends as of Jan 1, 1995.  Please do not\n");
  130.   printf("email resposes after that date.\n\n\n");
  131.   printf("Press any key to begin testing...\n");
  132.   getch();
  133.  
  134.                                     /*********************
  135.                                     *                    *
  136.                                     * Write questionaire *
  137.                                     * to output file     *
  138.                                     *                    *
  139.                                     *********************/
  140.  
  141.   fprintf(output,"[BEGIN DATA]\n");
  142.   fprintf(output,"SVGA Diagnostic Utility - Output file\n");
  143.   fprintf(output,"VERSION %s\n",version);
  144.   getdate(&today);
  145.   gettime(&now);
  146.   sprintf(string,"Created on %d/%d/%d at %d:%d\n",
  147.                 today.da_mon,today.da_day,today.da_year,
  148.                 now.ti_hour,now.ti_min);
  149.   fprintf(output,string);
  150.   fprintf(output,"Please email this file to smeagol@rt66.com before Jan 1, 1995\n");
  151.  
  152.   fprintf(output,"--------------------------------------------------------------\n\n");
  153.   fprintf(output,"Please include the following information about your system:\n\n");
  154.  
  155.   fprintf(output,"[COMPUTER]\n\n");
  156.  
  157.   fprintf(output,"                     CPU:\n");
  158.   fprintf(output,"    Clock Speed (in Mhz):\n");
  159.   fprintf(output,"           Cache (in Kb):\n");
  160.   fprintf(output,"      Ram Memory (In Mb):\n");
  161.   fprintf(output,"            Manufacturer:\n");
  162.   fprintf(output,"              Bios Maker:\n");
  163.   fprintf(output,"               Bios Date:\n\n");
  164.  
  165.   fprintf(output,"[VIDEO CARD]\n\n");
  166.  
  167.   fprintf(output,"            Manufacturer:\n");
  168.   fprintf(output,"                   Model:\n");
  169.   fprintf(output,"         Video BIOS date:\n");
  170.   fprintf(output,"    Video Memory (In MB):\n");
  171.   fprintf(output,"                Bus type:\n\n\n");
  172.  
  173.   fprintf(output,"(Note: You can get a lot of this information from a program\n");
  174.   fprintf(output,"called MSD.EXE that comes with later versions of MSDOS and WINDOWS.)\n\n\n");
  175.  
  176.   fprintf(output,"Finally, please add brief, descriptive comments of any \n");
  177.   fprintf(output,"problems you observed:\n\n\n\n\n\n\n");
  178.  
  179.   fprintf(output,"**********************************************************************\n");
  180.   fprintf(output,"*                                                                    *\n");
  181.   fprintf(output,"*    The section below contains results compiled by the utility.     *\n");
  182.   fprintf(output,"*             Please do not alter this data.                         *\n");
  183.   fprintf(output,"*                                                                    *\n");
  184.   fprintf(output,"**********************************************************************\n\n");
  185.  
  186.  
  187.                                     /*********************
  188.                                     *                    *
  189.                                     * Get General VESA   *
  190.                                     * information        *
  191.                                     *                    *
  192.                                     *********************/
  193.  
  194.  
  195.   clrscr();
  196.   printf("GENERAL VESA INFORMATION\n\n");
  197.   fprintf(output,"[GENERAL VESA INFORMATION]\n\n");
  198.  
  199.  
  200.   myregs.x.ax = 0x4f00;                   // set interrupt inputs
  201.   mysregs.es = _ES;
  202.   myregs.x.di = FP_OFF(vesainfobuffer);
  203.  
  204.   int86x(0x10,&myregs,&myregs,&mysregs);  // call the VESA information interrupt
  205.  
  206.   if(myregs.h.ah > 0 || myregs.h.al != 0x4f ) {  // if VESA call failed
  207.  
  208.     if(myregs.h.al != 0x4f) {             // Supported?
  209.       fprintf(output,"  BIOS VESA information call not supported.\n\n");
  210.       printf("*ERROR*\n\nBIOS VESA information call not supported.\n\n");
  211.     }
  212.     else {                                // Simple failure?
  213.       fprintf(output,"  BIOS VESA information call failed.\n\n");
  214.       printf("*ERROR*\n\nBIOS VESA information call failed.\n\n");
  215.     }
  216.     printf("If you continue, this program will behave unpredictably.\n");
  217.     printf("Most likely, it will crash and you will have to reboot\n");
  218.     printf("your system.\n\n\n");
  219.     printf("Do you wish to continue with the diagnostics? (Y/N)\n");
  220.  
  221.     while(kbhit()) getch();                // clear keyboardbuffer
  222.     r = toupper(getch());                 // get keystroke
  223.     if(r != 'Y') exit(2);
  224.   }
  225.  
  226.                                           /* SIGNATURE */
  227.   for(i = 0; i < 4; i++) {
  228.     string[i] = vesainfobuffer[i];        // copy signature bytes to a string
  229.   }
  230.   string[4] = 0;
  231.   printf("  Signature: %s\n",string);
  232.   fprintf(output,"  Signature: %s\n",string);
  233.                                             /* VESA Version # */
  234.   vermin = vesainfobuffer[0x04];
  235.   vermaj = vesainfobuffer[0x05];
  236.   printf("  VESA Version: %d.%d\n",vermaj,vermin);
  237.   fprintf(output,"  VESA Version: %d.%d\n",vermaj,vermin);
  238.  
  239.                                             /* Manufacturer */
  240.   pt = (byte *)&OEMname;
  241.   *(pt+0) = vesainfobuffer[0x06];           // set string pointer
  242.   *(pt+1) = vesainfobuffer[0x07];
  243.   *(pt+2) = vesainfobuffer[0x08];
  244.   *(pt+3) = vesainfobuffer[0x09];
  245.   for(i = 0 ; i < 200 && *(OEMname+i) != 0; i++); // Make string is real
  246.   if(i < 200) {
  247.     printf("  Manufacturer: %s\n",OEMname);
  248.     fprintf(output,"  Manufacturer: %s\n",OEMname);
  249.   }
  250.   else {
  251.     printf("  Manufacturer: [ERROR]");
  252.     fprintf(output,"  Manufacturer: [ERROR]");
  253.   }
  254.  
  255.                                             /* Memory (reports memory in
  256.                                                64 Kb chunnks */
  257.   video_memory = (vesainfobuffer[0x12]+ vesainfobuffer[0x13]) * 64 ;
  258.   printf("  Memory: %d Kb\n",video_memory);
  259.   fprintf(output,"  Memory: %d Kb\n",video_memory);
  260.  
  261.  
  262.   printf("\n\nPress any key to continue.\n");
  263.  
  264.                                     /*********************
  265.                                     *                    *
  266.                                     * SVGACC ID Fuctions *
  267.                                     *                    *
  268.                                     *********************/
  269.  
  270.   fprintf(output,"\n[SVGACC ID FUNCTIONS]\n\n");
  271.  
  272.   cputype = whichcpu();             // cpu type
  273.   fprintf(output,"  CPU: %d\n",cputype);
  274.   if(cputype < 386) {
  275.     printf("The CPU detected (%d) is too whimpy to run\n",cputype);
  276.     printf("the rest of this program.  Exiting....\n\n");
  277.     exit(1);
  278.   }
  279.  
  280.  
  281.   videocard = whichvga();           // Initialize graphics
  282.   if(videocard < 1 || videocard > 20) videocard = 21;
  283.   fprintf(output,"  Card: %s\n",card[videocard-1]);
  284.  
  285.   video_memory = whichmem();        // video memory
  286.   fprintf(output,"  Memory: %d\n",video_memory);
  287.  
  288.  
  289.   whichmouse_return = whichmouse(); // # of mouse buttons  0 = no mouse
  290.   fprintf(output,"  Whichmouse: %d\n",whichmouse_return);
  291.  
  292.                                     // other mouse info
  293.   mouseinfo(&mouse_drvmaj,&mouse_drvmin,&mousetype,&mouseirq);
  294.   fprintf(output,"    Driver Version: %.2lf\n",
  295.                  (double)mouse_drvmaj+mouse_drvmin/100.0);
  296.   fprintf(output,"    Type: %s\n",mice[mousetype]);
  297.   fprintf(output,"    IRQ: %d\n",mouseirq);
  298.  
  299.   if(videocard == 21) {             // whoops! no recognizeable video card
  300.     clrscr();
  301.     printf("*ERROR* The graphics library could not ID your card.\n");
  302.     printf("If you continue, this program will behave unpredictably.\n");
  303.     printf("Most likely, it will crash and you will have to reboot\n");
  304.     printf("your system.\n\n\n");
  305.     printf("Do you wish to continue with the diagnostics? (Y/N)\n");
  306.  
  307.     while(kbhit()) getch();              // clear keyboardbuffer
  308.     r = toupper(getch());
  309.     if(r != 'Y') exit(2);
  310.   }
  311.                                     // CHECK VIDEO MODES
  312.  
  313.   res1280_return = -1;              // -1 means not tested
  314.   res1024_return = -1;
  315.   if(video_memory > 2000) {         // if enough memory...
  316.     res1280_return = res1280();
  317.     fprintf(output,"  Res1280: %d\n",res1280_return);
  318.   }
  319.   if(video_memory > 1000) {
  320.     res1024_return = res1024();
  321.     fprintf(output,"  Res1024: %d\n",res1024_return);
  322.   }
  323.   res800_return = res800();
  324.   fprintf(output,"  Res800: %d\n",res800_return);
  325.  
  326.   res640_return = res640();
  327.   fprintf(output,"  Res640: %d\n",res640_return);
  328.  
  329.   pagedisplay_return = pagedisplay(0,0,0);    // pageflippping flag
  330.   fprintf(output,"  Pagedisplay: %d\n",pagedisplay_return);
  331.  
  332.   pageactive_return = pageactive(0); // page writing flag
  333.   fprintf(output,"  Pageactive: %d\n",pageactive_return);
  334.  
  335.   blkget_return = blkget(10,10,11,11,blk);  // looking at this just for kicks
  336.   fprintf(output,"  Blkget: %d\n",blkget_return);
  337.  
  338.                                     /***********************
  339.                                     *                      *
  340.                                     * SVGACC Compatability *
  341.                                     *                      *
  342.                                     ***********************/
  343.  
  344.   fprintf(output,"\n[REALITY CHECK]\n\n");
  345.   while(kbhit()) getch();
  346.                                     // Paging check
  347.   if(pagedisplay_return) {
  348.     fillpage(0);                    // page flipping
  349.     pageactive(0);
  350.     drwstring(SET,15,0,"THIS TEXT SHOULD BE BLINKING",200,100);
  351.     drwstring(SET,14,0,"Is the text above blinking? (Y/N)",200,150);
  352.     pageactive(1);
  353.     drwstring(SET,14,0,"Is the text above blinking? (Y/N)",200,150);
  354.     pageactive(0);
  355.  
  356.     r = ' ';
  357.     while(r != 'Y' && r != 'N') {
  358.       if(kbhit()) r = toupper(getch());
  359.       pagedisplay(0,0,1);
  360.       delay(40);
  361.       pagedisplay(0,0,0);
  362.       delay(40);
  363.     }
  364.     fprintf(output,"  page flipping: %c\n",r);
  365.                                     // page data writing
  366.     pageactive(1);                  // Draw a circle on page 1
  367.     drwfillcircle(SET,12,20,20,19);
  368.  
  369.     pageactive(0);                  // clear page 0;
  370.     fillpage(0);
  371.  
  372.     pageactive(1);                  // get the circle on page 1
  373.     blkget(0,0,40,40,blk);
  374.     fillpage(0);
  375.  
  376.     pageactive(0);                  // draw a bunch of what we got back there
  377.     for (i = 0; i < 10 ; i++) {
  378.       blkput(SET,i*60,30,blk);
  379.     }
  380.                                     // Did the user see it?
  381.     drwstring(SET,14,0,"Do you see a row of circles above? (Y/N)",200,150);
  382.  
  383.     while(kbhit()) getch();
  384.     r = ' ';
  385.     while(r != 'Y' && r != 'N') {
  386.       if(kbhit()) r = toupper(getch());
  387.     }
  388.     fprintf(output,"  page writing: %c\n",r);
  389.  
  390.   }
  391.   if(whichmouse_return) {           // Make sure the mouse is behaving itself
  392.     fillpage(5);
  393.     for(i = 0 ; i < 47; i++) {
  394.       drwfillbox(SET,4,0,i*10,640,i*10+5);
  395.     }
  396.  
  397.     mousecursordefault();           // start up the mouse
  398.     mouseenter();
  399.     mouseshow();
  400.  
  401.  
  402.     drwstring(SET,15,0,"Try moving your mouse around the screen",200,150);
  403.     drwstring(SET,15,0,"Does it mess up the screen? (Y/N)",200,170);
  404.  
  405.     while(kbhit()) getch();
  406.     r = ' ';
  407.     while(r != 'Y' && r != 'N') {
  408.       if(kbhit()) r = toupper(getch());
  409.     }
  410.     fprintf(output,"  Mouse mess: %c\n",r);
  411.     mousehide();
  412.   }
  413.  
  414.                                     /***********************
  415.                                     *                      *
  416.                                     * SVGACC Performance   *
  417.                                     *                      *
  418.                                     ***********************/
  419.  
  420.   fprintf(output,"\n[PERFORMANCE CHECK]\n\n");
  421.   while(kbhit()) getch();
  422.  
  423.   fillpage(0);                        // clear screeen
  424.   drwstring(SET,15,0,"SVGA PERFORMANCE CHECK",10,50);
  425.   delay(1000);                        // wait a second to enhance drama
  426.                                       // draw a pretty circle
  427.   drwfillbox(SET,0,250,0,450,300);
  428.   for(i = 16; i > 0; i--) drwfillcircle(SET,32-i,300-(16-i),100-(16-i),i*3.1);
  429.  
  430.   drwstring(SET,14,0,"TESTING BLOCK GET FUNCTION",10,80);
  431.   c = 0;                              // reset counter
  432.   t = clock();                        // look at clock
  433.   while(t == clock());                // start off on a tick
  434.   t += 51;                             // set alarm for 50 ticks (2.75 secs)
  435.   while(t != clock()) {               // loop until alarm
  436.     blkget(250,c%370,350,c%370+100,blk);       // drawing item to be tested
  437.     c++;                              //  increment counter
  438.   }
  439.   pps = c * 10000/2.75;               // calculate pixels/sec
  440.   fprintf(output,"  blkget: %.1lf Kpxls/sec\n",pps/1000.0);
  441.  
  442.   blkget(250,50,350,150,blk);         // get the picture
  443.   drwstring(SET,14,0,"TESTING BLOCK PUT FUNCTION",10,96);
  444.   c = 0;
  445.   t = clock();
  446.   while(t == clock());                // start off on a tick
  447.   t += 51;
  448.   while(t != clock()) {
  449.     blkput(SET,400,(c%370),blk);
  450.     c++;
  451.   }
  452.   pps = c * 10000/2.75;
  453.   fprintf(output,"  blkput: %.1lf Kpxls/sec\n",pps/1000.0);
  454.  
  455.   drwstring(SET,14,0,"TESTING DRAW BOX FUNCTION",10,112);
  456.   c = 0;
  457.   t = clock();
  458.   while(t == clock());                // start off on a tick
  459.   t +=51;
  460.   while(t != clock()) {
  461.     k = c &0xff;
  462.     for(i = 0; i < 10; i++) {
  463.       drwbox(SET,k,250 +k,100+k,350+k,200+k);
  464.     }
  465.     c++;
  466.   }
  467.   pps = c * 3980/2.75;
  468.   fprintf(output,"  drwbox: %.1lf Kpxls/sec\n",pps/1000.0);
  469.  
  470.   drwstring(SET,14,0,"TESTING DRAW FILLBOX FUNCTION",10,128);
  471.   c = 0;
  472.   t = clock();
  473.   while(t == clock());                // start off on a tick
  474.   t += 51;
  475.   while(t != clock()) {
  476.     k = c &0xff;
  477.     drwfillbox(SET,k,250 +k,100+k,350+k,200+k);
  478.     c++;
  479.   }
  480.   pps = c * 10000/2.75;
  481.   fprintf(output,"  drwfillbox: %.1lf Kpxls/sec\n",pps/1000.0);
  482.  
  483.   drwstring(SET,14,0,"TESTING DRAW LINE FUNCTION",10,144);
  484.   c = 0;
  485.   t = clock();
  486.   while(t == clock());                // start off on a tick
  487.   t += 51;
  488.   while(t != clock()) {
  489.     for(i = 0; i < 50; i++) {
  490.       drwline(SET,c%256,410,110,510,111);
  491.     }
  492.     c++;
  493.   }
  494.   pps = c * 5000/2.75;
  495.   fprintf(output,"  drwline: %.1lf Kpxls/sec\n",pps/1000.0);
  496.  
  497.   drwstring(SET,14,0,"TESTING DRAW POINT FUNCTION",10,160);
  498.   c = 0;
  499.   t = clock();
  500.   while(t == clock());                // start off on a tick
  501.   t += 51;
  502.   while(t != clock()) {
  503.     for(i = 200; i < 450; i++){
  504.       drwpoint(SET,c & 0xff,i,i);
  505.     }
  506.     c++;
  507.   }
  508.   pps = c *250 /2.75;
  509.   fprintf(output,"  drwpoint: %.1lf Kpxls/sec\n",pps/1000.0);
  510.  
  511.   drwstring(SET,14,0,"TESTING GET POINT FUNCTION",10,176);
  512.   c = 0;
  513.   t = clock();
  514.   while(t == clock());                // start off on a tick
  515.   t += 51;
  516.   while(t != clock()) {
  517.     for(i = 200; i < 450; i++){
  518.       getpoint(i,i);
  519.     }
  520.     c++;
  521.   }
  522.   pps = c *250 /2.75;
  523.   fprintf(output,"  getpoint: %.1lf Kpxls/sec\n",pps/1000.0);
  524.  
  525.  
  526.  
  527.                                       // All done!  Clean up and go home.
  528.   fprintf(output,"[END DATA]\n");
  529.  
  530.  
  531.  
  532.   restext();
  533.  
  534.   clrscr();
  535.   printf("Thanks for using this SVGA diagnostic Utility.\n");
  536.   printf("Please remember to edit the results file (SVGAOUT.TXT)\n");
  537.   printf("and fill in information about your system before emailing\n");
  538.   printf("it to smeagol@rt66.com\n");
  539.   fclose(output);
  540. }
  541.  
  542.